// pages/search/search.js
const searchPage = require("../../models/musicSearch")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  async onSubmit(event){
    // console.log(event.detail.value.content);
    var res = await searchPage(event.detail.value.content);
    console.log(res);
    this.setData({
      value:res.data.result.albums
    })
  },
  onChange(event){
    var value = this.data.value;
    value.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.state = !res.state;
      }else{
        res.state =false
      }
    })
    this.setData({
      value
    })
  }
})